package ai.people.core.feign.api.system;

import ai.people.core.feign.config.FeignConfig;
import ai.people.netmon.framework.domain.system.entity.NmSystemMenu;
import ai.people.netmon.framework.domain.system.entity.NmSystemRole;
import ai.people.netmon.framework.domain.system.entity.SystemDictData;
import ai.people.netmon.framework.domain.system.request.UpdatePasswordParam;
import ai.people.netmon.framework.domain.system.vo.NmSystemLoginUserVO;
import ai.people.netmon.framework.domain.system.vo.NmSystemUserSimpleVO;
import ai.people.netmon.framework.domain.system.vo.NmSystemUserVO;
import ai.people.netmon.framework.domain.ucenter.entity.NmSysRoles;
import ai.people.netmon.framework.domain.ucenter.entity.NmSysUser;
import ai.people.netmon.framework.model.response.ListResponse;
import ai.people.netmon.framework.model.response.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统API
 *
 * @author yuanqinglong
 * @date 2022/3/7 11:06
 */
@FeignClient(value = "NM-SERVICE-SYSTEM", path = "system",configuration = FeignConfig.class)
public interface SystemFeignClient {


    /**
     * 通过账号查询用户
     *
     * @param account 账户
     * @return {@link NmSysUser}
     */
    @GetMapping("/user/{account}")
    Result<NmSystemUserVO> getUserByAccount(@PathVariable("account") String account);


    /**
     * 得到longin用户帐户
     *
     * @param account 账户
     * @return {@link Result}<{@link NmSystemLoginUserVO}>
     */
    @GetMapping(value = "/user/login/account", consumes = "application/json; charset=UTF-8")
    Result<NmSystemLoginUserVO> getLonginUserByAccount(@RequestParam("account") String account);


    /**
     * 通过用户id查询菜单
     *
     * @param userId 用户id
     * @return {@link NmSysUser}
     */
    @GetMapping("/menu/listUserMenu")
    Result<List<NmSystemMenu>> getMenuByUserId(@RequestParam("userId") Long userId);

    /**
     * 通过用户id查询角色
     *
     * @param userId 用户id
     * @return {@link NmSysRoles}
     */
    @GetMapping("/role/userRoles")
    Result<List<NmSystemRole>> userRoles(@RequestParam("userId") Long userId);


    /**
     * 非管理用户
     *
     * @return {@link Result}<{@link ListResponse}<{@link NmSystemUserSimpleVO}>>
     */
    @GetMapping("/user/nonAdminUsers")
    Result<ListResponse<NmSystemUserSimpleVO>> nonAdminUsers();

    /**
     * 通过账号更新密码
     *
     * @param updatePasswordParam 更新密码参数
     * @return {@link Result}<{@link NmSystemUserVO}>
     */
    @PostMapping("/user/updatePassword")
    Result<NmSystemUserVO> updatePasswordByAccount(@RequestBody UpdatePasswordParam updatePasswordParam);


    /**
     * 更新最后登录时间
     *
     * @ignore
     * @param userId 用户id
     * @return {@link Result}<{@link ?}>
     */
    @PostMapping("/user/updateLoginTime")
    Result<?> updateLastLoginTime(@RequestParam("userId") Long userId);

    /**
     * 通过id查询用户
     *
     * @param id id
     * @return {@link Result}<{@link NmSystemUserVO}>
     */
    @GetMapping("/user/getUser")
    Result<NmSystemUserVO> getUserById(@RequestParam("id") Long id);


    /**
     * dict类型列表
     *
     * @param dictType dict类型
     * @return {@link Result}<{@link ListResponse}<{@link SystemDictData}>>
     */
    @GetMapping(value = "/dict/{dictType}")
    Result<ListResponse<SystemDictData>> dictList(@PathVariable("dictType") String dictType);

}
